package cn.fu.excle;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Demo {
	public static void main(String[] args) throws Exception  {  
           FileReader fr=new FileReader("D:\\new2.txt");
           String a = "群号";
           String b = "职务";
           String c = "姓名";
           String d = "性别";
           String e = "年龄";
           String f = "学历";
           String g = "民族";
           String h = "籍贯";
           String i = "手机号";
           String j = "身份证";
           String k = "农行卡";
           String l = "开户行";
           String m = "身份证地址";
           String n = "现住址";
           String o = "政治面貌";
           String p = "推荐人";
           String q = "退役军人";
           String r = "残疾人证号";
           String z = "填表说明";
           
           String tmp = ":";
           String tmp1= "：";
           BufferedReader br=new BufferedReader(fr);
           List<Map<String, String>> arrayList = new ArrayList<Map<String, String>>();

           Map<String, String> hashMap=null;
             int  x = 0;
             String line = "";
           while((line=br.readLine())!=null){
        	   line = line.replace(tmp, "");
        	   line =line.replace(tmp1, "");
        	   if(line.indexOf(a)> -1) {
        		   hashMap = new LinkedHashMap<String, String>();
        		   int indexOf = line.indexOf(a)+a.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(a, substring.trim());
        		   }
        	   }else if(line.indexOf(b)> -1) {
        		   int indexOf = line.indexOf(b)+b.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(b, substring.trim());
        		   }
        	   } else if(line.indexOf(c)> -1) {
        		   int indexOf = line.indexOf(c)+c.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(c, substring.trim());
        		   }
        	   } else if(line.indexOf(d)> -1) {
        		   int indexOf = line.indexOf(d)+d.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(d, substring.trim());
        		   }
        	   } else if(line.indexOf(e)> -1) {
        		   int indexOf = line.indexOf(e)+e.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(e, substring.trim());
        		   }
        	   } else if(line.indexOf(f)> -1) {
        		   int indexOf = line.indexOf(f);
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(f, substring.trim());
        		   }
        	   } else if(line.indexOf(g)> -1) {
        		   int indexOf = line.indexOf(g);
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(g, substring.trim());
        		   }
        	   } else if(line.indexOf(h)> -1) {
        		   int indexOf = line.indexOf(h)+h.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(h, substring.trim());
        		   }
        	   } else if(line.indexOf(i)> -1) {
        		   int indexOf = line.indexOf(i)+i.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(i, substring.trim());
        		   }
        	   } else if(line.indexOf(j)> -1) {
        		   int indexOf = line.indexOf(j)+j.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(j, substring.trim());
        		   }
        	   } else if(line.indexOf(k)> -1) {
        		   int indexOf = line.indexOf(k)+k.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(k, substring.trim());
        		   }
        	   }  else if(line.indexOf(l)> -1) {
        		   int indexOf = line.indexOf(l)+l.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(l, substring.trim());
        		   }
        	   } else if(line.indexOf(m)> -1) {
        		   int indexOf = line.indexOf(m)+m.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(m, substring.trim());
        		   }
        	   } else if(line.indexOf(n)> -1) {
        		   int indexOf = line.indexOf(n)+n.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(n, substring.trim());
        		   }
        	   } else if(line.indexOf(o)> -1) {
        		   int indexOf = line.indexOf(o)+o.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(o, substring.trim());
        		   }
        	   } else if(line.indexOf(p)> -1) {
        		   int indexOf = line.indexOf(p)+p.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(p, substring.trim());
        		   }
        	   } else if(line.indexOf(q)> -1) {
        		   int indexOf = line.indexOf(q)+q.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(q, substring.trim());
        		   }
        	   } else if(line.indexOf(r)> -1) {
        		   int indexOf = line.indexOf(r)+r.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(r, substring.trim());
        		   }
        	   }else if(line.indexOf(z)> -1) {
        		   int indexOf = line.indexOf(z)+z.length();
        		   String substring = line.substring(indexOf);
        		   if(substring != null && substring.trim() != "") {
        			   hashMap.put(z, substring.trim());
        		   }
        		   arrayList.add(hashMap);
        	   }              
          }  
           List<String[]> table = new ArrayList<String[]>();
           for (Map<String, String> map : arrayList) {
        	   String[] A = new String[19];  
        	   String sa = map.get(a);
        	   String sb = map.get(b);
        	   String sc = map.get(c);
        	   String sd = map.get(d);
        	   String se = map.get(e);
        	   String sf = map.get(f);
        	   String sg = map.get(g);
        	   String sh = map.get(h);
        	   String si = map.get(i);
        	   String sj = map.get(j);
        	   String sk = map.get(k);
        	   String sl = map.get(l);
        	   String sm = map.get(m);
        	   String sn = map.get(n);
        	   String so = map.get(o);
        	   String sp = map.get(p);
        	   String sq = map.get(q);
        	   String sr = map.get(r);
        	   String sz = map.get(z);
        	   
        	   A[0] = sa;
        	   A[1] = sb;
        	   A[2] = sc;
        	   A[3] = sd;
        	   A[4] = se;
        	   A[5] = sf;
        	   A[6] = sg;
        	   A[7] = sh;
        	   A[8] = si;
        	   A[9] = sj;
        	   A[10] = sk;
        	   A[11] = sl;
        	   A[12] = sm;
        	   A[13] = sn;
        	   A[14] = so;
        	   A[15] = sp;
        	   A[16] = sq;
        	   A[17] = sr;
        	   A[18] = sz;
        	   table.add(A);
		   }
//           arrayList.to
          ExcelUtils excelUtils = new ExcelUtils();
          excelUtils.toExcel(table,"d:\\aa.xlsx");
        }  
}
